package com.xaaef.jvm;

/**
 * <p>
 * </p>
 *
 * @author Wang Chen Chen<932560435@qq.com>
 * @date 2022/2/16 21:06
 */

public class ClassLoaderTest {

    public static void main(String[] args) {
        // 获取系统类加载器  sun.misc.Launcher$AppClassLoader@18b4aac2
        ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
        System.out.println(systemClassLoader);

        // 获取扩展类加载器  sun.misc.Launcher$ExtClassLoader@1b6d3586
        ClassLoader extClassLoader = systemClassLoader.getParent();
        System.out.println(extClassLoader);

        // 获取引导类加载器  null
        ClassLoader bootstrapClassLoader = extClassLoader.getParent();
        System.out.println(bootstrapClassLoader);

        // 获取当前类加载器  sun.misc.Launcher$AppClassLoader@18b4aac2
        ClassLoader testClassLoader = ClassLoaderTest.class.getClassLoader();
        System.out.println(testClassLoader);

        // 获取 String 类加载器  null
        ClassLoader stringClassLoader = String.class.getClassLoader();
        System.out.println(stringClassLoader);

    }

}
